package core.domain.messages;

import java.util.HashSet;
import java.util.Set;

import javax.xml.bind.annotation.XmlRootElement;

import core.domain.PeerDesciptor;
import core.domain.Torrent;

@XmlRootElement
public class GetPeersForTorrentMessage extends AbstractMessage {

	private static final long serialVersionUID = 3849455754108712022L;

	/**
	 * torrent is a file descriptor, retrieved from the Tracker, essential for
	 * the download.
	 */
	private Torrent torrent;

	/**
	 * peers registered at the tracker for this specific torrent
	 */
	private Set<PeerDesciptor> peers;

	protected GetPeersForTorrentMessage() {
		super(MessageType.GETPEERSFORTORRENT);
	}

	public GetPeersForTorrentMessage(Torrent torrent) {
		this();
		this.torrent = torrent;
		this.peers = new HashSet<PeerDesciptor>();
	}

	public Torrent getTorrent() {
		return torrent;
	}

	public void setTorrent(Torrent torrent) {
		this.torrent = torrent;
	}

	public Set<PeerDesciptor> getPeers() {
		return peers;
	}

	public void setPeers(Set<PeerDesciptor> peers) {
		this.peers = peers;
	}

	@Override
	public String toString() {
		return "GetPeersForTorrentMessage [torrent=" + torrent + ", peers=" + peers + "]";
	}

}
